/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Simulation.Services.Main;

import Simulation.Config.Service.ServiceConfigReader;
import Simulation.Messages.*;
import Simulation.Services.Common.ServiceComms;
import Simulation.Services.Ios.IosReorientJDialog;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 *
 * @author andy
 */
public class Ios extends javax.swing.JFrame {

    private ServiceConfigReader   config;
    private ServiceComms          comms;   
    private float                 GuiUpdatePeriod;
    private Message               interServiceMessage;  
    private IosMessageReader      iosMessageReader;
    private IosReorientJDialog    reorientDialog;
    
    private static final int  NUM_OF_SIMS = 4;
    private static final int  PERFORMANCE_AVERAGES = 50;
    //  Copies of data for more easily updating the GUI
    private javax.swing.JTable[] jTables = new javax.swing.JTable[NUM_OF_SIMS];
    private javax.swing.JPanel[] jBorders = new javax.swing.JPanel[NUM_OF_SIMS];
    
    private enum PerformnaceDisplayType {PERF_NONE, PERF_INPUT_LAG, PERF_INPUT_DUR, PERF_OUTPUT_LAG, OUTPUT_DUR};
    private PerformnaceDisplayType performnaceDisplay = PerformnaceDisplayType.PERF_NONE;
    
    
    private byte[] simulatorConfigurations = new byte[NUM_OF_SIMS];
    private PerformanceMessage[][][] performanceResults =
      new PerformanceMessage
        [NUM_OF_SIMS]
        [MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE]
        [PerformanceMessage.MAX_PERFORMANCE_TYPES];
    
    HealthMessage recordedHealthMessages[][] = new HealthMessage[NUM_OF_SIMS][MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1];
    
    long[][][] performanceProcessInputsLag      = new long[NUM_OF_SIMS][MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1][PERFORMANCE_AVERAGES];
    long[][][] performanceProcessInputsDuration = new long[NUM_OF_SIMS][MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1][PERFORMANCE_AVERAGES];
    long[][][] performanceSendOutputsLag        = new long[NUM_OF_SIMS][MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1][PERFORMANCE_AVERAGES];                            
    long[][][] performanceSendOutputsDuration   = new long[NUM_OF_SIMS][MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1][PERFORMANCE_AVERAGES];
    int[][] performanceProcessInputsLagIndex      = new int[NUM_OF_SIMS][MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1];
    int[][] performanceProcessInputsDurationIndex = new int[NUM_OF_SIMS][MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1];
    int[][] performanceSendOutputsLagIndex        = new int[NUM_OF_SIMS][MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1];                            
    int[][] performanceSendOutputsDurationIndex   = new int[NUM_OF_SIMS][MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1];      
    boolean[][] performanceProcessInputsLagAvailable        = new boolean[NUM_OF_SIMS][MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1];  
    boolean[][] performanceProcessInputsDurationAvailable   = new boolean[NUM_OF_SIMS][MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1];  
    boolean[][] performanceSendOutputsLagAvailable          = new boolean[NUM_OF_SIMS][MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1];  
    boolean[][] performanceSendOutputsDurationAvailable     = new boolean[NUM_OF_SIMS][MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1];  
    
    /**
     * Creates new form MainGui
     */
    public Ios() {
        
        initComponents();
        SetupTableData();
        SetupConfigData();
        DisplayConfig();
        StartService();
    }
    
    private class IosMessageReader extends Thread {   
        
        public void run() {

            System.out.println("Ios Message Rx Thread Running");
            while( true ) {

                Message msg = comms.RecieveMessage(0.0f);

                switch( msg.messageID ) {
                    case IOS_HEALTH:
                        RecordHealthMessage(msg);
                        break;   

                    case IOS_PERFORMANCE_RESULT:
                        RecordPerformanceResult(msg);
                        break;                    

                    default:
                        break;
                }     
            }
        }          
        
    }
    

   private void SetupTableData() {
        //associate tables with simulation number
        jTables[0] = jTable1;
        jTables[1] = jTable2;
        jTables[2] = jTable3;
        jTables[3] = jTable4;   
                
        
        for( int t=0; t<NUM_OF_SIMS; t++) {
            jTables[t].setValueAt("Sensors", 0, 0);
            jTables[t].setValueAt("Weapons", 1, 0);
            jTables[t].setValueAt("Dynamics", 2, 0);
            jTables[t].setValueAt("Behaviours", 3, 0);            

        }
   }
   
   private void SetupConfigData() {
        //associate tables with simulation number
        jBorders[0] = Sim1Border;
        jBorders[1] = Sim2Border;
        jBorders[2] = Sim3Border;
        jBorders[3] = Sim4Border;  
                
        simulatorConfigurations[0] = DesignateHostConfigMessage.SIM_TYPE_CR2_GVS;
        simulatorConfigurations[1] = DesignateHostConfigMessage.SIM_TYPE_WR_GVS;
        simulatorConfigurations[2] = DesignateHostConfigMessage.SIM_TYPE_CR2_VSS;
        simulatorConfigurations[3] = DesignateHostConfigMessage.SIM_TYPE_WR_VSS;                                   
   }   
    
   private void PeriodicGuiUpdateTick() {
       UpdateGui();             
   }   
   
      
    private synchronized void StorePerformanceProcessInputs(
        int simIn,
        int serviceIn,
        long referenceStartTimeIn,
        long serviceStartTimeIn,
        long serviceFinishTimeIn)
    {
        // Check that the data is valid. This helps us ignore the default startup data.
        if(serviceStartTimeIn >= referenceStartTimeIn) {
            
            performanceProcessInputsLag[simIn][serviceIn][performanceProcessInputsLagIndex[simIn][serviceIn]] =
            serviceStartTimeIn - referenceStartTimeIn;
            if( ++performanceProcessInputsLagIndex[simIn][serviceIn] >= PERFORMANCE_AVERAGES) {
                performanceProcessInputsLagIndex[simIn][serviceIn] = 0;
                if(serviceIn < MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1) {
                    performanceProcessInputsLagAvailable[simIn][serviceIn] = true;
                }

            }

            performanceProcessInputsDuration[simIn][serviceIn][performanceProcessInputsDurationIndex[simIn][serviceIn]] =
            serviceFinishTimeIn - serviceStartTimeIn;
            if( ++performanceProcessInputsDurationIndex[simIn][serviceIn] >= PERFORMANCE_AVERAGES) {
                performanceProcessInputsDurationIndex[simIn][serviceIn] = 0;     
                if(serviceIn < MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1) {
                    performanceProcessInputsDurationAvailable[simIn][serviceIn] = true;
                }
            }
        }
    }       

    private synchronized void StorePerformanceSendOutputs(
        int simIn,
        int serviceIn,
        long referenceStartTimeIn,
        long serviceStartTimeIn,
        long serviceFinishTimeIn)
    {
        
        // Check that the data is valid. This helps us ignore the default startup data.
        if(serviceStartTimeIn >= referenceStartTimeIn) {        
        
            performanceSendOutputsLag[simIn][serviceIn][performanceSendOutputsLagIndex[simIn][serviceIn]] =
            serviceStartTimeIn - referenceStartTimeIn;
            if( ++performanceSendOutputsLagIndex[simIn][serviceIn] >= PERFORMANCE_AVERAGES) {
                performanceSendOutputsLagIndex[simIn][serviceIn] = 0;
                if(serviceIn < MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1) {
                    performanceSendOutputsLagAvailable[simIn][serviceIn] = true;
                }
            }

            performanceSendOutputsDuration[simIn][serviceIn][performanceSendOutputsDurationIndex[simIn][serviceIn]] =
            serviceFinishTimeIn - serviceStartTimeIn;
            if( ++performanceSendOutputsDurationIndex[simIn][serviceIn] >= PERFORMANCE_AVERAGES) {
                performanceSendOutputsDurationIndex[simIn][serviceIn] = 0;
                if(serviceIn < MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1) {
                    performanceSendOutputsDurationAvailable[simIn][serviceIn] = true;      
                }
            }
        }
    }    
    
    private synchronized void UpdateGui()
    {
        long    microSeconds = 0;
        long    averageMicroSeconds = 0;  
        boolean available = false;
        
        // Show Health Data
        for(int sim=0;sim<NUM_OF_SIMS;sim++) {
            for(int ser=0;ser<MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1;ser++) {               
               jTables[sim].setValueAt(
                 MessageCommonConstants.StringForSimStatus(recordedHealthMessages[sim][ser].GetSimStatus()),
                 ser,
                 1);
               jTables[sim].setValueAt(
                 HealthMessage.StringForStatus(recordedHealthMessages[sim][ser].GetHealthStatus()),
                 ser,
                 2);           
            }
        }
        
        // Show Performance Data
        switch(performnaceDisplay) {
    
            case PERF_NONE:
                
                for(int sim=0;sim<NUM_OF_SIMS;sim++) {
                    for(int ser=0;ser<MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1;ser++) {               
                    jTables[sim].setValueAt(
                        "",
                        ser,
                        3);      
                    }
                }
                break;

            case PERF_INPUT_LAG:
            case PERF_INPUT_DUR:
            case PERF_OUTPUT_LAG:
            case OUTPUT_DUR:                

                for(int sim=0;sim<NUM_OF_SIMS;sim++) {
                    for(int ser=0;ser<MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1;ser++) {   

                        for( int avIndex=0; avIndex<PERFORMANCE_AVERAGES; avIndex++) {
                            switch(performnaceDisplay) {    
                                case PERF_INPUT_LAG:    microSeconds = performanceProcessInputsLag[sim][ser][avIndex]; break;
                                case PERF_INPUT_DUR:    microSeconds = performanceProcessInputsDuration[sim][ser][avIndex]; break;
                                case PERF_OUTPUT_LAG:   microSeconds = performanceSendOutputsLag[sim][ser][avIndex]; break;
                                case OUTPUT_DUR:        microSeconds = performanceSendOutputsDuration[sim][ser][avIndex]; break;
                            }    
                            microSeconds /= 1000;
                            averageMicroSeconds += microSeconds;
                        }
                        averageMicroSeconds /= PERFORMANCE_AVERAGES;

                        // Check if valid data available
                        available = false;
                        switch(performnaceDisplay) {    
                            case PERF_INPUT_LAG:    available = performanceProcessInputsLagAvailable[sim][ser];         break;
                            case PERF_INPUT_DUR:    available = performanceProcessInputsDurationAvailable[sim][ser];    break;
                            case PERF_OUTPUT_LAG:   available = performanceSendOutputsLagAvailable[sim][ser];           break;
                            case OUTPUT_DUR:        available = performanceSendOutputsDurationAvailable[sim][ser];      break;
                            default:                available = false;                                                  break;
                        }                           
                        
                        if( available ) {
                            if( averageMicroSeconds < 1000 ) {
                                jTables[sim].setValueAt(
                                "< 1 ms",
                                ser,
                                3);                             
                            } else {
                                jTables[sim].setValueAt(
                                (String.valueOf((averageMicroSeconds/1000)) + "ms"),
                                ser,
                                3);                             
                            }   
                        } else {
                            jTables[sim].setValueAt(
                            "N/A",
                            ser,
                            3);                              
                        }
                    }
                }
                break;
        }       
    }    
   
   private void RecordPerformanceResult(Message msg) {
       
       PerformanceMessage perfMessage = new PerformanceMessage(msg);
       long referenceStartTime;
       long serviceStartTime;
       long serviceFinishTime;
       
       /*
        * A performance message has some IDs inside it.
        * Make sure they are within the expected range.
        */
       if( perfMessage.GetSimulatorId() >=1 && perfMessage.GetSimulatorId() <= NUM_OF_SIMS) {
           if( perfMessage.GetServiceId() >=1 && perfMessage.GetServiceId() <= MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE) {
               if( perfMessage.GetPerformanceId() > PerformanceMessage.PERFORMANCE_UNKNOWN && 
                   perfMessage.GetPerformanceId() <= PerformanceMessage.MAX_PERFORMANCE_TYPES) {

                   /*
                    * When we get a performance result, all of the main service timings are 
                    * relative to the sync sub-service timings, so use the arrival of a new sync
                    * result to correlate the old frames results before we save the new messages data.
                    */
                   if( (perfMessage.GetServiceId() == MessageCommonConstants.SYNC_SUB_SERVICE ) &&
                       ( perfMessage.GetPerformanceId() == PerformanceMessage.PERFORMANCE_PROCESS_INPUTS ||
                         perfMessage.GetPerformanceId() == PerformanceMessage.PERFORMANCE_SEND_OUTPUTS ))
                        {       
                            
                       // The start time is the time when the SYNC_SUB_SERVICE issued the start message
                       referenceStartTime = performanceResults
                            [perfMessage.GetSimulatorId()-1]
                            [perfMessage.GetServiceId()-1]
                            [perfMessage.GetPerformanceId()-1].GetStartTime();
                        
                       // Loop through all service results                       
                       for( int i=0; i<(MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1); i++ ) {

                            // The start time, per service
                            serviceStartTime = performanceResults
                                [perfMessage.GetSimulatorId()-1]
                                [i]
                                [perfMessage.GetPerformanceId()-1].GetStartTime();
                            
                            // The finish time, per service
                            serviceFinishTime = performanceResults
                                [perfMessage.GetSimulatorId()-1]
                                [i]
                                [perfMessage.GetPerformanceId()-1].GetFinishTime();
    
                            if(perfMessage.GetPerformanceId() == PerformanceMessage.PERFORMANCE_PROCESS_INPUTS){    
                                
                                StorePerformanceProcessInputs(
                                  perfMessage.GetSimulatorId()-1,
                                  i,
                                  referenceStartTime,
                                  serviceStartTime,
                                  serviceFinishTime);
                            } else if(perfMessage.GetPerformanceId() == PerformanceMessage.PERFORMANCE_SEND_OUTPUTS) {

                                StorePerformanceSendOutputs(
                                  perfMessage.GetSimulatorId()-1,
                                  i,
                                  referenceStartTime,
                                  serviceStartTime,
                                  serviceFinishTime);
                            }
                       } // end loop all services                        
                    } // end if sync sub-service for PERFORMANCE_PROCESS_INPUTS |PERFORMANCE_SEND_OUTPUTS
                   
                    // Just store the data
                    performanceResults
                      [perfMessage.GetSimulatorId()-1]
                      [perfMessage.GetServiceId()-1]
                      [perfMessage.GetPerformanceId()-1] = perfMessage;                                           
               }
           }
       }
   }
   
   
   private synchronized void RecordHealthMessage(Message msg) { 
       HealthMessage healthMessage = new HealthMessage(msg);
       
       if( healthMessage.GetSimulator() >=1 && healthMessage.GetSimulator() <= 4) {
           if( healthMessage.GetService() >=1 && healthMessage.GetService() <= 4) {
               
               recordedHealthMessages[healthMessage.GetSimulator()-1][healthMessage.GetService()-1] =
                 healthMessage;         
           }
       }    
   }    
 
  
   
    private void DisplayConfig() {
        for( int t=0; t<NUM_OF_SIMS; t++) {
            jBorders[t].setBorder(
              javax.swing.BorderFactory.createTitledBorder(
                "Sim " +
                (t+1) +
                " (" +
                DesignateHostConfigMessage.StringForConfig(simulatorConfigurations[t]) +
                ")"));
        }        
    }
            
    private void StartService() {
        
        System.out.println("IOS Service Loading Config");   
        config = new ServiceConfigReader("Simulation/Config/Service/IosServiceConfig.txt");

        System.out.println("Ios Service Creating Read Socket");
        comms = new ServiceComms(
            config.GetData("IOS_READ_IP"),
            Integer.parseInt(config.GetData("IOS_READ_PORT"))
            );
        
        System.out.println("Ios Service Adding network destinations");   
        String datum = config.GetData("IOS_NUM_OF_NETWORK_DESTINATIONS");
        int num_of_network_destiantions = Integer.parseInt(datum);
        for( int i=0; i<num_of_network_destiantions; i++) {
            comms.AddIosDestiantion(
                config.GetData("IOS_NETWORK_DESTINATIONS_IP_" + String.valueOf(i+1)),
                Integer.parseInt(config.GetData("IOS_NETWORK_DESTINATIONS_PORT_" + String.valueOf(i+1))));
        }   
        GuiUpdatePeriod = Float.parseFloat(config.GetData("IOS_TICK_SECS"));   
        
        System.out.println("Ios Service Running");           


        
        // Create Default Performance values
        PerformanceMessage dummyPerfMessage = new PerformanceMessage(
              (byte) 0,
              (byte) 0,
              PerformanceMessage.PERFORMANCE_UNKNOWN,
              (byte) 0,
              (byte) 0);
        
        for(int a=0;a<NUM_OF_SIMS;a++)
            for(int b=0;b<MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE;b++)           
                for(int c=0;c<PerformanceMessage.MAX_PERFORMANCE_TYPES;c++)
                    performanceResults[a][b][c] = dummyPerfMessage;

        
        for(int a=0;a<NUM_OF_SIMS;a++)
            for(int b=0;b<MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1;b++) {
                performanceProcessInputsLagAvailable[a][b] = false;
                performanceProcessInputsDurationAvailable[a][b] = false;
                performanceSendOutputsLagAvailable[a][b] = false;
                performanceSendOutputsDurationAvailable[a][b] = false;                
            }        

        
        // Create Default health messages
        for(int a=0;a<NUM_OF_SIMS;a++) {
            for(int b=0;b<MessageCommonConstants.MAX_SERVICES_FOR_PERFORMANCE-1;b++) {
                recordedHealthMessages[a][b] = new HealthMessage(
                    (byte) a,
                    (byte) b,
                    MessageCommonConstants.SIM_STATE_UNDEFINED,
                    HealthMessage.STATUS_UNKNOWN);
            }
        }
                
        // Create a seperate thread to read IOS messsages independant of the GUI
        iosMessageReader = new IosMessageReader();
        iosMessageReader.start();         
        
        
        // Kick off a GUI compatable timer to trigger out GUI UPDATES from recieved data.
        javax.swing.Timer tm = new javax.swing.Timer(
            ((int)(GuiUpdatePeriod * 1000.0)),
            new ActionListener() {
                @Override
                public void actionPerformed(ActionEvent e) {
                    PeriodicGuiUpdateTick();
                }
            }
        );        
        tm.start();        
                
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jMenuBar1 = new javax.swing.JMenuBar();
        jMenu1 = new javax.swing.JMenu();
        jMenu2 = new javax.swing.JMenu();
        buttonGroup1 = new javax.swing.ButtonGroup();
        Sim1Border = new javax.swing.JPanel();
        Sim1Select = new javax.swing.JToggleButton();
        jScrollPane1 = new javax.swing.JScrollPane();
        jTable1 = new javax.swing.JTable();
        Sim2Border = new javax.swing.JPanel();
        Sim2Select = new javax.swing.JToggleButton();
        jScrollPane2 = new javax.swing.JScrollPane();
        jTable2 = new javax.swing.JTable();
        Sim3Border = new javax.swing.JPanel();
        Sim3Select = new javax.swing.JToggleButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTable3 = new javax.swing.JTable();
        Sim4Border = new javax.swing.JPanel();
        Sim4Select = new javax.swing.JToggleButton();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTable4 = new javax.swing.JTable();
        filler1 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));
        filler2 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));
        filler3 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));
        filler4 = new javax.swing.Box.Filler(new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 0), new java.awt.Dimension(0, 32767));
        jMenuBar2 = new javax.swing.JMenuBar();
        jMenu4 = new javax.swing.JMenu();
        StartSimulator = new javax.swing.JMenuItem();
        StopSimulator = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        jMenuItem5 = new javax.swing.JMenuItem();
        jMenuItem6 = new javax.swing.JMenuItem();
        jMenuItem7 = new javax.swing.JMenuItem();
        jMenuItem8 = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JPopupMenu.Separator();
        jMenuItem4 = new javax.swing.JMenuItem();
        jMenu5 = new javax.swing.JMenu();
        SetConfigGvsCr = new javax.swing.JMenuItem();
        SetConfigGvsWr = new javax.swing.JMenuItem();
        SetConfigGvsTitan = new javax.swing.JMenuItem();
        SetConfigVssCr = new javax.swing.JMenuItem();
        SetConfigVssWr = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        SaveConfig = new javax.swing.JMenuItem();
        SendConfig = new javax.swing.JMenuItem();
        jMenu3 = new javax.swing.JMenu();
        jMenuItem1 = new javax.swing.JMenuItem();
        jMenuItem10 = new javax.swing.JMenuItem();
        jMenuItem9 = new javax.swing.JMenuItem();
        jMenuItem11 = new javax.swing.JMenuItem();
        jSeparator4 = new javax.swing.JPopupMenu.Separator();
        jMenuItem12 = new javax.swing.JMenuItem();

        jMenu1.setText("File");
        jMenuBar1.add(jMenu1);

        jMenu2.setText("Edit");
        jMenuBar1.add(jMenu2);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("GBTT Manned Simulator IOS");

        Sim1Border.setBorder(javax.swing.BorderFactory.createTitledBorder("Sim 1"));

        buttonGroup1.add(Sim1Select);
        Sim1Select.setText("Select");

        jTable1.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Service", "Simulation Status", "Software Status", "Performance"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jTable1.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(jTable1);

        javax.swing.GroupLayout Sim1BorderLayout = new javax.swing.GroupLayout(Sim1Border);
        Sim1Border.setLayout(Sim1BorderLayout);
        Sim1BorderLayout.setHorizontalGroup(
            Sim1BorderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, Sim1BorderLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Sim1Select)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 753, Short.MAX_VALUE)
                .addContainerGap())
        );
        Sim1BorderLayout.setVerticalGroup(
            Sim1BorderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Sim1BorderLayout.createSequentialGroup()
                .addGroup(Sim1BorderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(Sim1Select, javax.swing.GroupLayout.DEFAULT_SIZE, 101, Short.MAX_VALUE))
                .addContainerGap())
        );

        Sim2Border.setBorder(javax.swing.BorderFactory.createTitledBorder("Sim 2"));

        buttonGroup1.add(Sim2Select);
        Sim2Select.setText("Select");

        jTable2.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Service", "Simulation Status", "Software Status", "Performance"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane2.setViewportView(jTable2);

        javax.swing.GroupLayout Sim2BorderLayout = new javax.swing.GroupLayout(Sim2Border);
        Sim2Border.setLayout(Sim2BorderLayout);
        Sim2BorderLayout.setHorizontalGroup(
            Sim2BorderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, Sim2BorderLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Sim2Select)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2)
                .addContainerGap())
        );
        Sim2BorderLayout.setVerticalGroup(
            Sim2BorderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Sim2BorderLayout.createSequentialGroup()
                .addGroup(Sim2BorderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(Sim2Select, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
                .addContainerGap())
        );

        Sim3Border.setBorder(javax.swing.BorderFactory.createTitledBorder("Sim 3"));

        buttonGroup1.add(Sim3Select);
        Sim3Select.setText("Select");

        jTable3.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Service", "Simulation Status", "Software Status", "Performance"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane3.setViewportView(jTable3);

        javax.swing.GroupLayout Sim3BorderLayout = new javax.swing.GroupLayout(Sim3Border);
        Sim3Border.setLayout(Sim3BorderLayout);
        Sim3BorderLayout.setHorizontalGroup(
            Sim3BorderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, Sim3BorderLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Sim3Select)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3)
                .addContainerGap())
        );
        Sim3BorderLayout.setVerticalGroup(
            Sim3BorderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Sim3BorderLayout.createSequentialGroup()
                .addGroup(Sim3BorderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(Sim3Select, javax.swing.GroupLayout.DEFAULT_SIZE, 102, Short.MAX_VALUE))
                .addContainerGap())
        );

        Sim4Border.setBorder(javax.swing.BorderFactory.createTitledBorder("Sim 4"));

        buttonGroup1.add(Sim4Select);
        Sim4Select.setText("Select");

        jTable4.setModel(new javax.swing.table.DefaultTableModel(
            new Object [][] {
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null},
                {null, null, null, null}
            },
            new String [] {
                "Service", "Simulation Status", "Software Status", "Performance"
            }
        ) {
            Class[] types = new Class [] {
                java.lang.String.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
            };
            boolean[] canEdit = new boolean [] {
                false, false, false, false
            };

            public Class getColumnClass(int columnIndex) {
                return types [columnIndex];
            }

            public boolean isCellEditable(int rowIndex, int columnIndex) {
                return canEdit [columnIndex];
            }
        });
        jScrollPane4.setViewportView(jTable4);

        javax.swing.GroupLayout Sim4BorderLayout = new javax.swing.GroupLayout(Sim4Border);
        Sim4Border.setLayout(Sim4BorderLayout);
        Sim4BorderLayout.setHorizontalGroup(
            Sim4BorderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, Sim4BorderLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Sim4Select)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane4)
                .addContainerGap())
        );
        Sim4BorderLayout.setVerticalGroup(
            Sim4BorderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(Sim4BorderLayout.createSequentialGroup()
                .addGroup(Sim4BorderLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                    .addComponent(Sim4Select, javax.swing.GroupLayout.DEFAULT_SIZE, 103, Short.MAX_VALUE))
                .addContainerGap())
        );

        jMenu4.setText("Control");

        StartSimulator.setText("Start Sim");
        StartSimulator.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                StartSimulatorActionPerformed(evt);
            }
        });
        jMenu4.add(StartSimulator);

        StopSimulator.setText("Stop Sim");
        StopSimulator.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                StopSimulatorActionPerformed(evt);
            }
        });
        jMenu4.add(StopSimulator);
        jMenu4.add(jSeparator2);

        jMenuItem5.setText("Reconstitute");
        jMenuItem5.setEnabled(false);
        jMenu4.add(jMenuItem5);

        jMenuItem6.setText("Resupply");
        jMenuItem6.setEnabled(false);
        jMenu4.add(jMenuItem6);

        jMenuItem7.setText("Reposition");
        jMenuItem7.setEnabled(false);
        jMenu4.add(jMenuItem7);

        jMenuItem8.setText("Reorient");
        jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem8ActionPerformed(evt);
            }
        });
        jMenu4.add(jMenuItem8);
        jMenu4.add(jSeparator3);

        jMenuItem4.setText("Restart SW");
        jMenuItem4.setEnabled(false);
        jMenu4.add(jMenuItem4);

        jMenuBar2.add(jMenu4);

        jMenu5.setText("Config");
        jMenu5.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenu5ActionPerformed(evt);
            }
        });

        SetConfigGvsCr.setText("GVS Challenger");
        SetConfigGvsCr.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SetConfigGvsCrActionPerformed(evt);
            }
        });
        jMenu5.add(SetConfigGvsCr);

        SetConfigGvsWr.setText("GVS Warrior");
        SetConfigGvsWr.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SetConfigGvsWrActionPerformed(evt);
            }
        });
        jMenu5.add(SetConfigGvsWr);

        SetConfigGvsTitan.setText("GVS Titan");
        SetConfigGvsTitan.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SetConfigGvsTitanActionPerformed(evt);
            }
        });
        jMenu5.add(SetConfigGvsTitan);

        SetConfigVssCr.setText("VSS Challenger");
        SetConfigVssCr.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SetConfigVssCrActionPerformed(evt);
            }
        });
        jMenu5.add(SetConfigVssCr);

        SetConfigVssWr.setText("VSS Warrior");
        SetConfigVssWr.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SetConfigVssWrActionPerformed(evt);
            }
        });
        jMenu5.add(SetConfigVssWr);
        jMenu5.add(jSeparator1);

        SaveConfig.setText("Save");
        SaveConfig.setEnabled(false);
        jMenu5.add(SaveConfig);

        SendConfig.setText("Send Config");
        SendConfig.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SendConfigActionPerformed(evt);
            }
        });
        jMenu5.add(SendConfig);

        jMenuBar2.add(jMenu5);

        jMenu3.setText("Performance");

        jMenuItem1.setText("Show Process Inputs Lag");
        jMenuItem1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem1ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem1);

        jMenuItem10.setText("Show Process Inputs Duration");
        jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem10ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem10);

        jMenuItem9.setText("Show Send Outputs Lag");
        jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem9ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem9);

        jMenuItem11.setText("Show Send Outputs Duration");
        jMenuItem11.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem11ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem11);
        jMenu3.add(jSeparator4);

        jMenuItem12.setText("Show None");
        jMenuItem12.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jMenuItem12ActionPerformed(evt);
            }
        });
        jMenu3.add(jMenuItem12);

        jMenuBar2.add(jMenu3);

        setJMenuBar(jMenuBar2);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Sim1Border, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addComponent(Sim4Border, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(filler3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                        .addGap(0, 0, Short.MAX_VALUE)
                        .addComponent(filler2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(202, 202, 202))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(Sim3Border, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addContainerGap())))
            .addGroup(layout.createSequentialGroup()
                .addGap(207, 207, 207)
                .addComponent(filler4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(Sim2Border, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(filler4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(134, 134, 134)
                        .addComponent(filler1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Sim1Border, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(18, 18, 18)
                .addComponent(Sim2Border, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(11, 11, 11)
                .addComponent(filler2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(171, 171, 171)
                        .addComponent(filler3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Sim3Border, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(Sim4Border, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void jMenuItem8ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem8ActionPerformed
        // TODO add your handling code here:
        // Create the reorientantion dialog
        reorientDialog = new IosReorientJDialog(this, true);
        reorientDialog.setVisible(true);
        
        if(reorientDialog.ok) {
            
        }
        
    }//GEN-LAST:event_jMenuItem8ActionPerformed

    private void SetConfigGvsTitanActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SetConfigGvsTitanActionPerformed
        // TODO add your handling code here:
        if(Sim1Select.isSelected()) {
            simulatorConfigurations[0] = DesignateHostConfigMessage.SIM_TYPE_TITAN_GVS;
        }
        if(Sim2Select.isSelected()) {
            simulatorConfigurations[1] = DesignateHostConfigMessage.SIM_TYPE_TITAN_GVS;
        }
        if(Sim3Select.isSelected()) {
            simulatorConfigurations[2] = DesignateHostConfigMessage.SIM_TYPE_TITAN_GVS;
        }
        if(Sim4Select.isSelected()) {
            simulatorConfigurations[3] = DesignateHostConfigMessage.SIM_TYPE_TITAN_GVS;
        } 
        
        DisplayConfig();     
    }//GEN-LAST:event_SetConfigGvsTitanActionPerformed

    private void SetConfigGvsCrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SetConfigGvsCrActionPerformed
        // TODO add your handling code here:
        if(Sim1Select.isSelected()) {
            simulatorConfigurations[0] = DesignateHostConfigMessage.SIM_TYPE_CR2_GVS;
        }
        if(Sim2Select.isSelected()) {
            simulatorConfigurations[1] = DesignateHostConfigMessage.SIM_TYPE_CR2_GVS;
        }
        if(Sim3Select.isSelected()) {
            simulatorConfigurations[2] = DesignateHostConfigMessage.SIM_TYPE_CR2_GVS;
        }
        if(Sim4Select.isSelected()) {
            simulatorConfigurations[3] = DesignateHostConfigMessage.SIM_TYPE_CR2_GVS;
        } 
        
        DisplayConfig();
    }//GEN-LAST:event_SetConfigGvsCrActionPerformed

    private void jMenu5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu5ActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jMenu5ActionPerformed

    private void SetConfigGvsWrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SetConfigGvsWrActionPerformed
        // TODO add your handling code here:
        // TODO add your handling code here:
        if(Sim1Select.isSelected()) {
            simulatorConfigurations[0] = DesignateHostConfigMessage.SIM_TYPE_WR_GVS;
        }
        if(Sim2Select.isSelected()) {
            simulatorConfigurations[1] = DesignateHostConfigMessage.SIM_TYPE_WR_GVS;
        }
        if(Sim3Select.isSelected()) {
            simulatorConfigurations[2] = DesignateHostConfigMessage.SIM_TYPE_WR_GVS;
        }
        if(Sim4Select.isSelected()) {
            simulatorConfigurations[3] = DesignateHostConfigMessage.SIM_TYPE_WR_GVS;
        } 
        
        DisplayConfig();
    }//GEN-LAST:event_SetConfigGvsWrActionPerformed

    private void SetConfigVssCrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SetConfigVssCrActionPerformed
        // TODO add your handling code here:
        if(Sim1Select.isSelected()) {
            simulatorConfigurations[0] = DesignateHostConfigMessage.SIM_TYPE_CR2_VSS;
        }
        if(Sim2Select.isSelected()) {
            simulatorConfigurations[1] = DesignateHostConfigMessage.SIM_TYPE_CR2_VSS;
        }
        if(Sim3Select.isSelected()) {
            simulatorConfigurations[2] = DesignateHostConfigMessage.SIM_TYPE_CR2_VSS;
        }
        if(Sim4Select.isSelected()) {
            simulatorConfigurations[3] = DesignateHostConfigMessage.SIM_TYPE_CR2_VSS;
        } 
        
        DisplayConfig();     
    }//GEN-LAST:event_SetConfigVssCrActionPerformed

    private void SetConfigVssWrActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SetConfigVssWrActionPerformed
        // TODO add your handling code here:
        if(Sim1Select.isSelected()) {
            simulatorConfigurations[0] = DesignateHostConfigMessage.SIM_TYPE_WR_VSS;
        }
        if(Sim2Select.isSelected()) {
            simulatorConfigurations[1] = DesignateHostConfigMessage.SIM_TYPE_WR_VSS;
        }
        if(Sim3Select.isSelected()) {
            simulatorConfigurations[2] = DesignateHostConfigMessage.SIM_TYPE_WR_VSS;
        }
        if(Sim4Select.isSelected()) {
            simulatorConfigurations[3] = DesignateHostConfigMessage.SIM_TYPE_WR_VSS;
        } 
        
        DisplayConfig();     
    }//GEN-LAST:event_SetConfigVssWrActionPerformed

    private void SendConfigActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SendConfigActionPerformed
        // TODO add your handling code here:
        DesignateHostConfigMessage cm = new DesignateHostConfigMessage();
        if(Sim1Select.isSelected()) {
            cm.SetSimulatorId( (byte) 1 );
            cm.SetSimulatorType(simulatorConfigurations[0]);
            comms.SendMessage(cm);
        }
        if(Sim2Select.isSelected()) {
            cm.SetSimulatorId( (byte) 2 );
            cm.SetSimulatorType(simulatorConfigurations[1]);
            comms.SendMessage(cm);
        }
        if(Sim3Select.isSelected()) {
            cm.SetSimulatorId( (byte) 3 );
            cm.SetSimulatorType(simulatorConfigurations[2]);
            comms.SendMessage(cm);
        }
        if(Sim4Select.isSelected()) {
            cm.SetSimulatorId( (byte) 4 );
            cm.SetSimulatorType(simulatorConfigurations[3]);
            comms.SendMessage(cm);
        } 
    }//GEN-LAST:event_SendConfigActionPerformed

    private void jMenuItem9ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
        // TODO add your handling code here:
        performnaceDisplay = PerformnaceDisplayType.PERF_OUTPUT_LAG;
    }//GEN-LAST:event_jMenuItem9ActionPerformed

    private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed
        // TODO add your handling code here:
        performnaceDisplay = PerformnaceDisplayType.PERF_INPUT_LAG;      
    }//GEN-LAST:event_jMenuItem1ActionPerformed

    private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem10ActionPerformed
        // TODO add your handling code here:
        performnaceDisplay = PerformnaceDisplayType.PERF_INPUT_DUR;
    }//GEN-LAST:event_jMenuItem10ActionPerformed

    private void jMenuItem11ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem11ActionPerformed
        // TODO add your handling code here:
        performnaceDisplay = PerformnaceDisplayType.OUTPUT_DUR;
    }//GEN-LAST:event_jMenuItem11ActionPerformed

    private void jMenuItem12ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem12ActionPerformed
        // TODO add your handling code here:
        performnaceDisplay = PerformnaceDisplayType.PERF_NONE;
    }//GEN-LAST:event_jMenuItem12ActionPerformed

    private void StartSimulatorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StartSimulatorActionPerformed
        // TODO add your handling code here:
        StartSimulationMessage ssm = new StartSimulationMessage();
        if(Sim1Select.isSelected()) {
            ssm.SetSimulatorId( (byte) 1 );
            comms.SendMessage(ssm);
        }
        if(Sim2Select.isSelected()) {
            ssm.SetSimulatorId( (byte) 2 );
            comms.SendMessage(ssm);
        }
        if(Sim3Select.isSelected()) {
            ssm.SetSimulatorId( (byte) 3 );
            comms.SendMessage(ssm);
        }
        if(Sim4Select.isSelected()) {
            ssm.SetSimulatorId( (byte) 4 );
            comms.SendMessage(ssm);
        }         
    }//GEN-LAST:event_StartSimulatorActionPerformed

    private void StopSimulatorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_StopSimulatorActionPerformed
        // TODO add your handling code here:
        StopSimulationMessage ssm = new StopSimulationMessage();
        if(Sim1Select.isSelected()) {
            ssm.SetSimulatorId( (byte) 1 );
            comms.SendMessage(ssm);
        }
        if(Sim2Select.isSelected()) {
            ssm.SetSimulatorId( (byte) 2 );
            comms.SendMessage(ssm);
        }
        if(Sim3Select.isSelected()) {
            ssm.SetSimulatorId( (byte) 3 );
            comms.SendMessage(ssm);
        }
        if(Sim4Select.isSelected()) {
            ssm.SetSimulatorId( (byte) 4 );
            comms.SendMessage(ssm);
        }           
    }//GEN-LAST:event_StopSimulatorActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /*
         * Set the Nimbus look and feel
         */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /*
         * If Nimbus (introduced in Java SE 6) is not available, stay with the
         * default look and feel. For details see
         * http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(Ios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(Ios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(Ios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(Ios.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /*
         * Create and display the form
         */
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new Ios().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem SaveConfig;
    private javax.swing.JMenuItem SendConfig;
    private javax.swing.JMenuItem SetConfigGvsCr;
    private javax.swing.JMenuItem SetConfigGvsTitan;
    private javax.swing.JMenuItem SetConfigGvsWr;
    private javax.swing.JMenuItem SetConfigVssCr;
    private javax.swing.JMenuItem SetConfigVssWr;
    private javax.swing.JPanel Sim1Border;
    private javax.swing.JToggleButton Sim1Select;
    private javax.swing.JPanel Sim2Border;
    private javax.swing.JToggleButton Sim2Select;
    private javax.swing.JPanel Sim3Border;
    private javax.swing.JToggleButton Sim3Select;
    private javax.swing.JPanel Sim4Border;
    private javax.swing.JToggleButton Sim4Select;
    private javax.swing.JMenuItem StartSimulator;
    private javax.swing.JMenuItem StopSimulator;
    private javax.swing.ButtonGroup buttonGroup1;
    private javax.swing.Box.Filler filler1;
    private javax.swing.Box.Filler filler2;
    private javax.swing.Box.Filler filler3;
    private javax.swing.Box.Filler filler4;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenu jMenu2;
    private javax.swing.JMenu jMenu3;
    private javax.swing.JMenu jMenu4;
    private javax.swing.JMenu jMenu5;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JMenuBar jMenuBar2;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem10;
    private javax.swing.JMenuItem jMenuItem11;
    private javax.swing.JMenuItem jMenuItem12;
    private javax.swing.JMenuItem jMenuItem4;
    private javax.swing.JMenuItem jMenuItem5;
    private javax.swing.JMenuItem jMenuItem6;
    private javax.swing.JMenuItem jMenuItem7;
    private javax.swing.JMenuItem jMenuItem8;
    private javax.swing.JMenuItem jMenuItem9;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JPopupMenu.Separator jSeparator3;
    private javax.swing.JPopupMenu.Separator jSeparator4;
    private javax.swing.JTable jTable1;
    private javax.swing.JTable jTable2;
    private javax.swing.JTable jTable3;
    private javax.swing.JTable jTable4;
    // End of variables declaration//GEN-END:variables
}
